package com.apes.enquiry.supplier.santouliubi.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.audit.Auditing;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.HashMap;
import java.util.Map;

/**
 * 类描述：门店管理
 *
 * @ClassName ShopManagement
 * @Description 描述
 * @Author wushilong
 * @Date 2022/12/13 10:26
 * @Version 1.0
 */
@Auditing
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = ShopManagement.CONST_TABLE_NAME)
public class ShopManagement extends Model {
    public static final String CONST_TABLE_NAME = "sp_mas_shop_management";

    @Id
    @Column(name = "id", length = 10)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "三头六臂门店管理", padding = 3, prefix = "ST%(company)", useDateRange = true)
    @Comment("编码")
    private String id;

    @Column(name = "name", length = 32)
    @Comment("名称")
    private String name;

    @Column(name = "store_id",nullable = false, length = 32)
    @Comment("门店编号")
    private String storeId;

    @Column(name = "store_name", nullable = false, length = 32)
    @Comment("门店名称")
    private String storeName;

    @Column(name = "company", nullable = false, length = 32)
    @Comment("公司ID")
    private String company;

    @Column(name = "approval", nullable = false, length = 16)
    @Comment("审核状态描述")
    private String approval;

    @Column(name = "status", length = 16)
    @Comment("审核状态")
    private String status;//5:待匹配;10:待审核;20:已作废;30:审核不通过;40:审核通过

    @Column(name = "state", nullable = false)
    @Comment("状态")
    private boolean state = false;

    @Column(name = "contacts", nullable = false, length = 16)
    @Comment("门店联系人")
    private String contacts;

    @Column(name = "contact_phone", nullable = false, length = 24)
    @Comment("门店联系电话")
    private String contactPhone;

    @Column(name = "city", nullable = false, length = 16)
    @Comment("城市")
    private String city; //城市

    @Column(name = "address", length = 32)
    @Comment("门店详细地址")
    private String address;

    @Column(name = "santou_id", length = 16)
    @Comment("三头修理厂编码")
    private String santouId;

    @Column(name = "valid", nullable = false)
    @Comment("审核通过")
    private boolean valid = false;

    @Column(name = "note")
    @Comment("备注")
    private String note;

    @Column(name = "channel_number")
    @Comment("渠道码")
    private String channelNumber;

    @Column(name = "channel_name")
    @Comment("渠道名称")
    private String channelName;


    @Transient
    private Map channel;//渠道

    public Map getChannel() {
        if (channel == null){
            channel = new HashMap();
        }
        channel.put("channelNumber", channelNumber);
        channel.put("channelName", channelName);
        return channel;
    }
}
